Learning the bash shell by Cameron Newham; Bill Rosenblatt

Learning the bash shell by Cameron Newham; Bill Rosenblatt

Author:Cameron Newham; Bill Rosenblatt
Language: eng
Format: mobi
Tags: Reference:Computers
ISBN: 9780596009656
Publisher: Beijing ; O'Reilly, 2005.
Published: 2009-02-09T00:00:00+00:00


eval $convert $filename $scale $border $standardise > $outfile

Now consider what happens when we don't want to scale the image. We do this:

scale=""

while getopts ":s:w:c:" opt; do

case $opt in

s ) scale=' | pnmscale' ;;

...

eval $convert $filename $scale $border $standardise > $outfile

In this code fragment, scale is set to a default of the empty string. If -s is not given on the command line, then the final line evaluates with $scale as the empty string and the pipeline will "collapse" into:

$convert $filename $border $standardise > $outfile

Using this principle, we can modify the previous version of the procimage script and produce a pipeline version. For each input file we need to construct and run a pipeline based upon the options given on the command line. Here is the new version:

# Set up the defaults

width=1

colour='-color grey'

usage="Usage: $0 [-s N] [-w N] [-c S] imagefile..."



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.